//
//  PersonalPortraitCell.m
//  Cunli
//
//  Created by lilubin on 15/7/1.
//  Copyright (c) 2015年 lilubin. All rights reserved.
//

#import "PersonalPortraitCell.h"
#import "UIImageView+WebCache.h"

@interface PersonalPortraitCell ()

@end

@implementation PersonalPortraitCell

/*
- (void)awakeFromNib {
    // Initialization code
    [super awakeFromNib];
    if (_portraitURLStr.length != 0) {
        //
        [_portraitImageView setImage:_portraitImage];
    }
    else
    {
        [_portraitImageView setImage:[UIImage imageNamed:@"default_news"]];
    }
}
*/
- (void)layoutSubviews
{
    [super layoutSubviews];
    NSURL *picURL = [NSURL URLWithString:_portraitURLStr];
    NSLog(@"In personalPortrailCell porURL:%@", _portraitURLStr);
    //    [_portraitImageView setImageWithURL:picURL];
    [_portraitImageView setImageWithURL:picURL placeholderImage:[UIImage imageNamed:@"default_news"]];
    
    [_portraitImageView.layer setCornerRadius:35];
    _portraitImageView.layer.masksToBounds = YES;
    _portraitImageView.translatesAutoresizingMaskIntoConstraints = NO;
    
}

- (void)setPortraitURLStr:(NSString *)portraitURLStr
{
    if (![_portraitURLStr isEqualToString:portraitURLStr]) {
        _portraitURLStr = portraitURLStr;
        [_portraitImageView setImageWithURL:[NSURL URLWithString:portraitURLStr] placeholderImage:[UIImage imageNamed:@"default_news"]];
    }
}

- (void)setPortraitImage:(UIImage *)portraitImage
{
    if (_portraitImage != portraitImage) {
        [_portraitImageView setImage:portraitImage];
    }
    _portraitImage = portraitImage;
}

@end
